{extend name="default/template/base_index"/}

{block name="area_header"}

{/block}

{block name="area_body"}
    {include file="default/Widget/topbar" /}
    <div class="admin-main container-fluid">
        {include file="default/Widget/left" /}
        <div class="admin-main-content">
            {include file="default/Widget/breadcrumb" /}
            <!-- 过滤\查询按钮 -->
            <div class="filter-controls">
                <!-- 日期查询 -->
                <form action="{:url('Stores/index')}" method="post" class="form-inline">
                    <div class="form-group">
                        <label>店铺名称</label>
                        <input type="text" name="name" value="{$name}" class="form-control input-sm"
                               placeholder="店铺名称"/>
                        <td>
                            <select id="province" name="province"  class="addr_value" onchange="pac(this.value,'city');pac($('#city').val(),'area');">
                                <option  value=0>不限</option>
                                {volist name=":getPCAlist(1,'province')" id="vo"}
                                <option  value="{$vo.provinceID}">{$vo.province}</option>
                                {/volist}
                            </select>

                            <select id="city" name="city" class="addr_value" onchange="pac(this.value,'area')">
                                <option  value=0>不限</option>
                                {volist name=":getPCAlist(110000,'city')" id="vo"}
                                <option  value="{$vo.cityID}">{$vo.city}</option>
                                {/volist}
                            </select>
                            <select id="area" name="area" class="addr_value">
                                <option  value=0>不限</option>
                                {volist name=":getPCAlist(110000,'area')" id="vo"}
                                <option  value="{$vo.areaID}">{$vo.area}</option>
                                {/volist}
                            </select>
                        </td>
                    </div>
                    <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i>{:L('BTN_SEARCH')}
                    </button>
                </form>
            </div>
            <!-- 操作按钮 -->
            <div class="btn-controls">
                <a class="btn btn-primary btn-sm" href="{:url('Stores/add',array('id'=>$id,'leave'=>$leave))}"><i class="fa fa-plus"></i>{:L('BTN_ADD')}</a>
            </div>
            <table class="table table-striped table table-hover  table-condensed">
                <thead>
                <tr>
                    <th style="width: 120px;">
                        店铺ID
                    </th>
                    <th style="width: 120px;">
                        店铺名/logo
                    </th>
                    <th style="width: 120px;">
                        客服电话
                    </th>
                    <th style="width: 120px;">
                        店铺级别
                    </th>
                    <th style="width: 120px;">
                        所在城市
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                </thead>
                <tbody>
                {empty name="list"}
                    <tr>
                        <td colspan="5" class="text-center">{:L('NO_DATA')}</td>
                    </tr>
                    {else/}
                    {volist name="list" id="vo"}
                        <tr>
                            <td>
                                {$vo.id}
                            </td>
                            <td><a href="{:url('Stores/index',array('id'=>$vo['id'],'leave'=>$vo['leave']))}" >{$vo.name}</a>

                                <img class="thumbnail" style="width:60px;height: 60px;"
                                               src="{:getImgUrl($vo['logo'])}" alt='logo'/>
                            </td>
                            <td>
                                {$vo.phone}
                            </td>
                            <td>
                                {$vo.leave}
                            </td>
                            <td>
                                {:getCity($vo.city)}
                            </td>
                            <td>



                                {eq name="$vo['uid']" value=":UID"}
                                <a href="{:url('Stores/edit',array('id'=>$vo['id']))}" class="btn btn-primary btn-sm"><i
                                        class="fa fa-edit "></i>编辑</a>
                                {/eq}
                                <a href="{:url('Store/delete',array('id'=>$vo['id']))}"
                                   class="ajax-get confirm btn btn-primary btn-sm hidden"><i class="fa fa-trash"></i>删除</a>
                        </tr>
                    {/volist}
                {/empty}
                </tbody>
            </table>
            <div>{$show}</div>
        </div>

        <script type="text/javascript">

//	$(function(){
//		pac(1,"province");//生成所有省
//		pac($("#province").val(),"city");//生成，默认省的市
//		pac($("#city").val(),"area");//生成，默认市的区
//	})
            function pac(code,type){
                $.ajax({
                    url:"{:url('PCA/pac')}",
                    type:"post",
                    data:{
                        type:type,
                        code:code
                    },
                    async:false,

                    dataType:"json",
                    success:function(data){
                        //1.清空option
                        $("#"+type).html("");
                        $("#"+type).append("<option value=0>"+'不限'+"</option>");
                        for(var i=0;i<data['info'].length;i++){
                            //2.追加option
                            $("#"+type).append("<option value='"+data['info'][i][1]+"'>"+data['info'][i][2]+"</option>");
                        }
                    }

                })
            }

        </script>
    </div>
    <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
{/block}

{block name="area_footer"}

{/block}